package cn.codergege.demo.Service;

import cn.codergege.demo.dao.EmployeeRepository;
import cn.codergege.demo.domain.Employee;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {
    private final Logger log = LoggerFactory.getLogger(EmployeeService.class);

    @Autowired
    private EmployeeRepository employeeRepository;

    /**
     * 查询所有 employees
     * @return 所有的 employees
     */
    public List<Employee> getAllEmployees() {
        List<Employee> employees = employeeRepository.findAll();
        return employees;
    }

    /**
     * 添加 employee
     * @param employee
     */
    public void save(Employee employee) {
        employeeRepository.save(employee);
    }
}
